﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using BLL.SystemManagement;

namespace Garlic.BasicInfo
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }



        //-----Pop----


        public void BindVessels()
        {
            DataTable vesselstable = VesselsBLL.GetAllVessels();

            ddlVesselsENnameAndCodePop.DataValueField = "vsl_id";
            ddlVesselsENnameAndCodePop.DataTextField = "vsname";
            ddlVesselsENnameAndCodePop.DataSource = vesselstable;
            ddlVesselsENnameAndCodePop.DataBind();

            GetVesselsByIDPop();
        }



        protected void ddlVesselsENnameAndCodePop_SelectedIndexChanged(object sender, EventArgs e)
        {
            GetVesselsByIDPop();
        }
        public void GetVesselsByIDPop()
        {
            string vsl_id = ddlVesselsENnameAndCodePop.SelectedValue;
            if (!string.IsNullOrEmpty(vsl_id))
            {
                DataTable vesseltb = VesselsBLL.GetVesselsByID(int.Parse(vsl_id));
                txt_VSL_CNnamePop.Text = vesseltb.Rows[0]["vsl_cnname"].ToString();
            }
        }

        protected void btnFlt_schdulPop_Click(object sender, EventArgs e)
        {
            Flt_schdulPop();
        }

        private void Flt_schdulPop()
        {
            int flt_sln_id = 0;
            int.TryParse(ServiceRouteTreePop1.ServiceRouteID.ToString(), out flt_sln_id);
            if (flt_sln_id != 0)
            {
                DataTable flt_schdul = FlightInfoBLL.GetFlt_schdulDataTable(flt_sln_id);
                ddlFlt_schdulPop.DataTextField = "flt_schdul";
                ddlFlt_schdulPop.DataValueField = "flt_id";
                ddlFlt_schdulPop.DataSource = flt_schdul;
                ddlFlt_schdulPop.DataBind();
            }
            else
            {
                ddlFlt_schdulPop.Items.Clear();
            }
        }
    }
}